﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Test.Models;
using Test.Util;

namespace Test.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
        string appid = "wx86f7d7caa4e5b3a9";
        string secret = "793f436b1b918b677a6d4c0e8966f810";
        public ContentResult Test()
        {
            //var w = HttpContext.Current.Request;
            string echostr = Request["echostr"];
            HttpHelper httpHelper = new HttpHelper();
            HttpItem item = new HttpItem();
            item.URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret;
            HttpResult result= httpHelper.GetHtml(item);
            if (result.StatusCode == HttpStatusCode.OK)
            {
                WXTokenResultModel model = JsonHelper.JsonToObject<WXTokenResultModel>(result.Html);
            }
            return Content(echostr);
        }
        public ContentResult templateMessage()
        {
            return Content("");
        }
        public ContentResult Test1()
        {
            //var w = HttpContext.Current.Request;
            string echostr = Request["echostr"];
            HttpHelper httpHelper = new HttpHelper();
            HttpItem item = new HttpItem();
            item.Method = "POST";
            item.URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret;
            item.Postdata = "{path: 'pages/index/index',width: 430}";
            HttpResult result = httpHelper.GetHtml(item);
            if (result.StatusCode == HttpStatusCode.OK)
            {
                WXTokenResultModel model = JsonHelper.JsonToObject<WXTokenResultModel>(result.Html);
            }
            return Content(echostr);
        }
    }
}